//
//  ViewController.m
//  UI06_UINavigationController
//
//  Created by Hanlingyu on 16/7/21.
//  Copyright © 2016年 ltq. All rights reserved.
//

#import "ViewController.h"
#import "PushViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    // 设置navigationBar的属性
    self.title = @"我是标题";
    self.navigationItem.title = @"sdfasdsa";
    UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"王璜", @"韩旭"]];
    segment.frame = CGRectMake(100, 100, 150, 44);
    // 标题视图, 修改x, y对视图本身没有影响
    self.navigationItem.titleView = segment;
    //
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(comeBack:)];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(bookMarkAction:)];
    
    
    // 6. rightBarButtonItems 数组
    // barButtonItems 数组中放1-2个Item为优
    // 7. 隐藏navgationbar YES 隐藏, NO, 不隐藏默认为NO
//    self.navigationController.navigationBarHidden = YES;
//    self.navigationController.navigationBar.hidden = YES;
    
    // 8.navgationBar背景样式, 默认为 default
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    // 9.navgationBar的背景颜色
    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
    // 10.
    self.navigationController.navigationBar.barTintColor = [UIColor redColor];
    // 11. tintColot bar上元素的颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    // 12.translucent 管理半透明效果, YES为开启, NO为关闭
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.backgroundColor = [UIColor blueColor];
    button.frame = CGRectMake(0, 0, 200, 200);
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    // 设置为YES时, self.view坐标系从原点开始
    // 设置为NO时, self.view坐标系从navgationBar下开始
//    self.navigationController.navigationBar.translucent = NO;
    // 13. 改变坐标效果, 与translucent为NO的效果一样
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    // 页面跳转相关
    // 1. push
    // 2. pop
    // 3. viewControllers存放navgationController里所有的控制器
//    self.navigationController.viewControllers
    
    // 4.topViewController 栈顶试图控制器(最后入栈)

    // 5.visibleViewController 可见视图控制器
}

- (void)buttonClicked:(UIButton *)button {
    // 将视图控制器入栈
    [self.navigationController pushViewController:[[PushViewController alloc] init] animated:YES];
}






- (void)bookMarkAction:(UIBarButtonItem *)barButtonItem {
    NSLog(@"啊哈哈");
}

- (void)comeBack:(UIBarButtonItem *)barButtonItem {
    NSLog(@"返回");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
